package com.kgis.map.task.query {
    import com.kgis.map.Map;
    import com.kgis.map.RemoteCaller;
    import com.kgis.map.layer.LayerData;

    import mx.rpc.AsyncResponder;
    import mx.rpc.AsyncToken;
    import mx.rpc.events.ResultEvent;
    import com.kgis.map.task.query.Query;

    /**
     * 通过objectid查询矢量设施
     */
    public class LayerObjectIdQuery extends Query {
        //图层id
        private var _layerId:Number;
        //设施id
        private var _objectId:Number;

        public function LayerObjectIdQuery(layerId:Number, objectId:Number) {
            this._layerId = layerId;
            this._objectId = objectId;
            super("getLayerDataByLayerIdObjectId");
        }

        override public function execute():void {
            if (null == onResult)
                return;
            // var remoteCaller:RemoteCaller = new RemoteCaller(map.serverUrl, "spatialDataManagementService", null);
            var remoteCaller:RemoteCaller = new RemoteCaller("spatialDataManagementService");
            var token:AsyncToken = remoteCaller.remoteObject.getOperation(operationName).send(layerId, objectId);
            token.addResponder(new AsyncResponder(onQueryResult, onQueryFault));
        }

        /**根据图层id和objectid获取 矢量设施数据*/
        private function onQueryResult(event:ResultEvent, token:Object = null):void {
            var layerData:LayerData = event.result as LayerData;

            onResult(layerData, token);
        }

        public function get layerId():Number {
            return _layerId;
        }

        public function set layerId(value:Number):void {
            _layerId = value;
        }

        public function get objectId():Number {
            return _objectId;
        }

        public function set objectId(value:Number):void {
            _objectId = value;
        }


    }
}